package com.jeasonzhao.report.model;

import com.jeasonzhao.report.codes.DataSetCellTypes;
import com.jeasonzhao.report.codes.ReportAlertModels;

public class ReportAlertCollection extends java.util.Vector<ReportAlert>
{
    private static final long serialVersionUID = 1L;
    public ReportAlertCollection()
    {
        super();
    }

    public ReportAlertCollection findByMode(ReportAlertModels mode,DataSetCellTypes cellTypes)
    {
        ReportAlertCollection ret = new ReportAlertCollection();
        for(int n = 0;n < this.size();n++)
        {
            ReportAlert alert = this.get(n);
            if(null == alert)
            {
                continue;
            }
            if(alert.getAlertModel().equals(mode) && alert.isMatchCellType(cellTypes))
            {
                ret.add(alert);
            }
        }
        return ret;
    }

    public static ReportAlertCollection from(Iterable<ReportAlert> colls)
    {
        if(null == colls)
        {
            return null;
        }
        ReportAlertCollection coll = new ReportAlertCollection();
        for(java.util.Iterator<ReportAlert> it = colls.iterator();it.hasNext();)
        {
            coll.add(it.next());
        }
        return coll;
    }
}
